﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;

namespace LModels
{
    public class Measurements : BaseModel
    {
        public Measurements(Proxy.Proxy pxProxy, string description) : base(pxProxy)
        {
            Description = description;
        }

        public string Description { get; set; }

        public Measurements(string description)
        {
            Description = description;
        }


        protected internal override BaseModel Load(long IDMeasurement)
        {

            IDataReader dr = base.px.Measurement.Load(IDMeasurement);

            try
            {
                dr.Read();
                SetPK(dr["IDMeasurement"] == DBNull.Value ? -1 : (long) dr["IDMeasurement"]);
                Description = dr["Description"].ToString();

                return this;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

        }
    }
}
